#ifndef SQLQUERY_H
#define SQLQUERY_H

#include <QDialog>
#include <QSqlQuery>
#include <QVariant>
#include <QLineEdit>

namespace Ui {
class SqlQuery;
}

class SqlQuery : public QDialog
{
    Q_OBJECT
    
public:
    explicit SqlQuery(QWidget *parent = 0);
    ~SqlQuery();

    void loadQuery(const QString &filename);
    
private slots:
    void execButtonPressed();
    void exportToExcel();
private:
    void initColumns(const QVariantList &names);
    void initArgs(const QVariantList &args);
    void execQuery(const QString &query, int columns);

    Ui::SqlQuery *ui;
    QSqlQuery sql;
    QVariantMap m_query;
    QList<QLineEdit *> m_args;
};

#endif // SQLQUERY_H
